linux rsync + inotify搭建实时网页发布同步系统

葫芦的运维日志

下一篇 搜索 上一篇

浏览量 3744

2014/01/29 18:22


WEB服务器

[root@localhost ~]# cat /etc/rsyncd.conf

#如果不加这行strict modes = false,可能会出现@ERROR: auth failed on module mysql
strict modes = false
#只允许192.168.1.0 网段下的客户端同步,也可指定IP。www.linuxidc.com 多个IP用逗号且无空格连接,如192.168.1.2,192.168.1.3
#也可用:hosts deny = 0.0.0.0/32
hosts allow = 192.168.0.166/32
log file = /var/log/rsyncd.log
#pid file = /var/run/rsyncd.pid #指定rsync的pid文件,可不用。#motd file = /etc/rsyncd.motd #欢迎信息文件名称和存放位置(此文件没有,可以自行添加)
#lock file = /var/run/rsync.lock #指定支持max connections参数的锁文件,默认值
#max connections = 10   # 最大连接数为10

[web]  #指定认证的备份模块名为mysql,在client端需要指定
#备份路径
path= /var/www
#验证用户,这行如果不用,则可匿名访问,多个用户用逗号“,”分隔
#不建议用root。
auth users = wangzi

#备份以什么用户ID和组ID进行,也可用root
#但建议用mysql用户去读,只要设置有足够权限的用户即可,不建议用root.
uid = root
gid = root

# 可以忽略一些无关的IO错误
ignore errors

#不允许列文件
list = false

#密码验证文件:username:password
secrets file = /etc/rsyncd.secrets

#关闭只读,可以上传
read only = no
write only = no

#pid file = /var/run/rsyncd.pid
#log file = /var/log/rsyncd.log
#lock file = /var/run/rsync.lock

#trict modes = false,可能会出现@ERROR: auth failed on module mysql
#只允许192.168.1.0 网段下的客户端同步,也可指定IP。www.linuxidc.com 多个IP用逗号

#motd file = /etc/rsyncd.motd #欢迎信息文件名称和存放位置(此文件没有,可以自行>添加)
#lock file = /var/run/rsync.lock #指定支持max connections参数的锁文件,默认值

 


 

[root@localhost ~]# cat /etc/rsyncd.secrets
****:****


 

[root@localhost ~]# rsync --daemon --config=/etc/rsyncd.conf


 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


 

发布服务器

 

uname -r

 

确认下是否内核版本高于2.6.13

 

安装inotify-tools

 

./configure

 

make

 

make install



[root@wangzi ~]# cat /var/www/inotify
#!/bin/bash
host1=192.168.0.166
src=/var/www/wangmai
dst1=web
user1=wangzi
/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y' --format '%T %w%f%e' -e modify,delete,create,attrib $src \
| while read files
do
/usr/bin/rsync -vzrtopg --delete --progress --password-file=/etc/server.pass $src $user1@$host1::$dst1
echo "${file} was rsynced" >>/tmp/rsync.log 2>&1
done

 

[root@wangzi akismet]# cat /etc/exclude_wangmai.txt
home/logs

[root@wangzi akismet]# cat /etc/server.pass
****

chmod 755 /var/www/inotify

nohup /var/www/inotify &

葫芦的运维日志

打赏

上一篇 搜索 下一篇
© 冰糖葫芦甜(bthlt.com) 2021 王梓打赏联系方式 陕ICP备17005322号-1